001 /* 002 * Copyright 2005 Stephen J. McConnell. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 013 * implied. 014 * 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package net.dpml.state; 020 021 import java.io.Serializable; 022 023 /** 024 * Default implementation of an operation. 025 * 026 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a> 027 * @version 1.0.1 028 */ 029 public class DefaultInterface implements Interface, Serializable 030 { 031 private final String m_classname; 032 033 /** 034 * Creation of a new interface declaration. 035 * @param classname the overriding method name 036 * @exception NullPointerException if the operation name is null 037 */ 038 public DefaultInterface( String classname ) throws NullPointerException 039 { 040 if( null == classname ) 041 { 042 throw new NullPointerException( "classname" ); 043 } 044 m_classname = classname; 045 } 046 047 /** 048 * Overriden method returning the interface classname. 049 * @return the name (interface classname) 050 * @see #getClassname() 051 */ 052 public String getName() 053 { 054 return getClassname(); 055 } 056 057 /** 058 * Return the interface classname. 059 * @return the classname 060 */ 061 public String getClassname() 062 { 063 return m_classname; 064 } 065 066 /** 067 * Return a string representation of the instance. 068 * @return the string value 069 */ 070 public String toString() 071 { 072 return "interface:" + m_classname; 073 } 074 075 /** 076 * Compare this object to another for equality. 077 * @param other the other object 078 * @return true if the object is equal to this object 079 */ 080 public boolean equals( Object other ) 081 { 082 if( null == other ) 083 { 084 return false; 085 } 086 else if( other instanceof DefaultInterface ) 087 { 088 DefaultInterface description = (DefaultInterface) other; 089 return m_classname.equals( description.m_classname ); 090 } 091 else 092 { 093 return false; 094 } 095 } 096 097 /** 098 * Compute the hashcode for this instance. 099 * @return the hashcode value 100 */ 101 public int hashCode() 102 { 103 int hash = getClass().hashCode(); 104 hash ^= m_classname.hashCode(); 105 return hash; 106 } 107 }